<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="日期"
        width="180">
      </el-table-column>
    </el-table>

    <el-pagination
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="pageSize"
      :current-page="currentPage"
      @current-change="gotoPage">
    </el-pagination>
  </div>
</template>

<script>
// 引入axios
export default {
  data () {
    return {
      tableData: [],
      total: 0,
      pageSize: 5,
      currentPage:1
    }
  },
  methods:{
    getUserList(){
      this.$http.post("/user/list",{"currentPage":this.currentPage,"pageSize":this.pageSize})
                .then(result=>{
                  this.total = result.data.totals;
                  console.log(this.total);
                  console.log(this.pageSize);
                  this.tableData = result.data.data;
                }).catch(result=>{
                  alert(result)
                  alert("网络不太好")
                })
    },
    gotoPage(curr) {
      this.currentPage = curr;
      this.getUserList();
    }

  },
  mounted() {
    this.getUserList()
  }
}
</script>

<style>

</style>


